function showMom(fileStations,OptsGen,OptMom)
%showMom - show several mom timeseries
%
%   showMom(fileStations,OptsGen,OptMom)
%
% This function shows the GNSS time series in the mom files related to 
% the stations listed in filenaStations in accordance with the StaVelMain 
% options stored in the struct variable OptsGen. 
%
% Input variables:
%
% - filenaStations carries the list of GNSS stations, represented by their 
%   standard 4-character names. This file can be either an Excel or an 
%   ASCII file. In the case of Excel file, the station names must be placed
%   in the first column (no more than the first column is read). 
%   In the case of an ASCII file, only a column is admitted. 
%   If filenaStations is undefined or empty, the filename can be managed 
%   in interactive way.
%   Let statName be the string array with the station names.
%
% - OptsGen is a struct variable generated by means of geneOpts function.
%   The input tsData file is searched of the basis of the station name, 
%   statName(k), and information carried by OptsGen in accordance with:
%   filenats = fullfile(OptsGen.dirTs,[statName(k) OptsGen.AddTs '.mat']).
%   The tsData file is upgraded according to the detected offsets.
%   The corresponding mom observation files, whose names are stored in 
%   OptsGen, are also generated and/or upgraded.
%   If OptsGen is undefined or empty, the .mat file with such a struct
%   variable can be interactively managed. 
%
% - OptMom indicates which ones mom files must be shown: 'raw' for raw,
%   'obs' for observation, 'pre' for preprocessed, 'preCME' for CME-filtered,
%   proprocessed, 'mom' for final results (i.e. time series and model),
%  'momCME' for CME-filtered final results. If the user wants to see more 
%   than one kind of mom file, OptMom must be a cell variable (for example,
%   OptMom = {'raw','mom'} to see raw data and final results).
%   If OptMom is undefined or empty, OptMom = 'mom' is used.
%
% See also showMomSingle, StaVelMain, geneOpts.

% G. Teza, 2022

if nargin == 3 
    if ischar(OptMom) && ismember(OptMom,{'raw','obs','pre','mom','preCME','momCME'})   
        dirMomIn = {OptMom};
    elseif iscell(OptMom)
        Iok = ismember(OptMom,{'raw','obs','pre','mom','preCME','momCME'});
        dirMomIn = OptMom(Iok);
    else
        OptMom = [];
    end
end
if nargin < 3 || isempty(OptMom)
    dirMomIn = {'mom'};
end
if nargin < 2
    OptsGen = [];
end
if nargin < 1 
    fileStations = [];
end 

b = readStationList(fileStations);
if isempty(b) 
    return
else
    nin = size(b,1);
end

OptsGen = OptsGenLoad(OptsGen);
if isempty(OptsGen)
    return
end

nmom = numel(dirMomIn);
dirMom = cell(size(dirMomIn));
for k = 1:nmom
    strk = dirMomIn{k};
    if strcmpi(strk,'raw')
        dirMom(k) = {OptsGen.dirRaw};
    elseif strcmpi(strk,'obs')
        dirMom(k) = {OptsGen.dirObs};
    elseif strcmpi(strk,'pre')
        dirMom(k) = {OptsGen.dirPre};
    elseif strcmpi(strk,'preCME')
        dirMom(k) = {OptsGen.dirPreCME};
    elseif strcmpi(strk,'mom')
        dirMom(k) = {OptsGen.dirMom};
    elseif strcmpi(strk,'momCME')
        dirMom(k) = {OptsGen.dirMomCME};
    end
end

AddFiName = OptsGen.AddMom;
NC = numel(OptsGen.components);

for k = 1:nin
    namek = b{k,1};
    namek = strtrim(namek);     % to remove possible leading and trailing spaces
    namek = upper(namek);       % to warrant station name with capital letters
    if isempty(namek)
        continue
    end
    namek = upper(namek);
    showMomSingle(namek,AddFiName,dirMom,dirMomIn,NC);
end